import time
from Page2 import Page2
from selenium.webdriver.common.by import By
class Page3(Page2):
    # 点击登录
    denglu=(By.XPATH,'//*[@id="ttbar-login"]/a[1]')
    def denglu_loc(self):
        self.click(self.denglu)
    #     点击密码登录
    dianjimima=(By.ID,'pwd-login')
    def dianji_loc(self):
        self.click(self.dianjimima)
    #  输入用户名
    name = (By.NAME, 'loginname')
    def name_loc(self):
        self.send_keys(self.name, '18379340028')
    # 输入密码
    mima=(By.XPATH,'//*[@id="nloginpwd"]')
    def mima_loc(self):
        self.send_keys(self.mima,'002816hj')
    # 点击立即登录
    anniu=(By.XPATH,'//*[@id="loginsubmit"]')
    def anniu_loc(self):
        self.click(self.anniu)

    xw = (By.XPATH, '//*[@id="key"]')

    def xw_loc(self):
        self.send_keys(self.xw, '电脑')

    # 点击搜索按钮
    ss = (By.XPATH, '//*[@id="header_wrap"]/div/div[2]/div[1]/button')

    def ss_loc(self):
        self.click(self.ss)

    dy1 = (By.XPATH, '//*[@id="search-condition"]/div[1]/span')

    def dy1_loc(self):
        self.text(self.dy1)

    def baidu3(self):
        self.open('https://www.jd.com/')
        self.xw_loc()
        time.sleep(2)
        self.ss_loc()
        time.sleep(2)
        print(self.dy1_loc())
        time.sleep(5)
        self.denglu_loc()
        time.sleep(2)
        self.dianji_loc()
        time.sleep(2)
        self.name_loc()
        self.mima_loc()
        time.sleep(2)
        self.anniu_loc()
        time.sleep(10)

